﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using IOEntity;
using IODataAccess;
namespace IOBusiness
{
    public class clsBSNews
    {
        clsDANews obj = new clsDANews();
        public clsNews GetById(int id)
        {
            try
            {
                return obj.GetById(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsNews> GetAll()
        {
            try
            {
                return obj.GetAll();
            }
            catch (Exception)
            {

                throw;
            }
            
        }
        public List<clsNews> GetByLoai(int loaiid)
        {
            try
            {
                return obj.GetByLoai(loaiid);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsNews> GetByLoai(int loaiid,int id)
        {
            try
            {
                List<clsNews> loai1 = new List<clsNews>();
                List<clsNews> loai2 = new List<clsNews>();
                loai1=obj.GetByLoai(loaiid);
                for (int i = 0; i < loai1.Count; i++)
                {
                    if(loai2.Count<10&loai1[i].Id!=id)
                    {
                        loai2.Add(loai1[i]);
                    }
                }
                return loai2;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsNews> GetByTop(int top)
        {
            try
            {
                return obj.GetByTop(top);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public int Insert(clsNews obj)
        {
            try
            {
                return this.obj.Insert(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Update(clsNews obj)
        {
            try
            {
                this.obj.Update(obj);
            }
            catch (Exception)
            {

                throw;
            }
            
        }
        public void Delete(int id)
        {
            try
            {
                this.obj.Delete(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
